'''
@Company: TWL
@Author: xue jian
@Email: xuejian@kanzhun.com
@Date: 2020-04-09 19:41:01
'''
# -*- coding: UTF-8 -*-

import tensorflow as tf


def test_tf(model_path):
    sess = tf.Session()
    tf.saved_model.loader.load(sess, ['wide_deep'], model_path)
    feed_dict = {}
    fea_dict = {
        '125':100101,
        '391': 6,
        '118': 100101,
        '212': 9,
        '874': [5, 7, 6, 10, 9, 12, -3, -3, -3, -3],
        '880': [1, -3, -3, -3, -3, -3, -3, -3, -3, -3],
        '881': [2, 1, 3, -3, -3, -3, -3, -3, -3, -3],
        '875': [5, 6, 1, -3, -3, -3, -3, -3, -3, -3],
        '876': [10, 7, 9, -3, -3, -3, -3, -3, -3, -3]
    }
    for k, v in fea_dict.items():
        feed_dict[sess.graph.get_tensor_by_name(k + ":0")] = [v]
    output = sess.graph.get_tensor_by_name('predict:0')
    pred = sess.run(output, feed_dict=feed_dict)
    print(pred)


test_tf("/data1/zangruozhou/tf_model/success_deep_small/deepfm/")